package LevelEditor.main;

import basis.game.entities.Entity;
import basis.game.level.Level;
import basis.game.level.Terrain;
import basis.game.main.Renderable;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.util.ArrayList;
import java.util.List;

public class Plane implements Level{

    private double x,y,w,h;
    private boolean show;
    private ArrayList<Renderable> levels;
    
    public Plane(double x,double y,double w,double h){
        this.x=x;this.y=y;this.w=w;this.h=h;
        levels=new ArrayList<Renderable>();
    }
    
    @Override
    public Terrain[] getTerrain() {
        return null;
    }

    @Override
    public Entity[] getEntities() {
        return null;
    }

    @Override
    public List<Renderable> getObjects() {
        return levels;
    }

    @Override
    public Terrain getTerrainAt(double x, double y) {
        return null;
    }

    @Override
    public double getTerrainSize() {
        return 0;
    }

    @Override
    public double getWidth() {
        return w;
    }

    @Override
    public double getHeight() {
        return h;
    }

    @Override
    public void setX(double x) {
        for(Renderable r:levels){
            double cx=r.getX()-this.x;
            r.setX(x+cx);
        }
        this.x=x;
    }

    @Override
    public void setY(double y) {
        for(Renderable r:levels){
            double cy=r.getY()-this.y;
            r.setY(y+cy);
        }
        this.y=y;
    }

    @Override
    public void show(boolean s) {
        show=s;
    }

    @Override
    public void move(double x, double y) {
        this.x+=x;
        this.y+=y;
    }

    @Override
    public void update(long t) {
        for(Renderable r:levels){
            if(r!=null)
                r.update(t);
        }
    }
    
    public void add(Renderable r){
        levels.add(r);
    }

    @Override
    public void render(Graphics2D g) {
        g.setColor(Color.white);
        g.fillRect((int)x,(int)y,(int)w,(int)h);
        for(Renderable r:levels){
            if(r!=null)
                r.render(g);
        }
    }

    @Override
    public double getX() {
        return x;
    }

    @Override
    public double getY() {
        return y;
    }

    @Override
    public boolean isShown() {
        return show;
    }

    @Override
    public Shape getBounds() {
        return null;
    }
    
}